To achieve flexible and manageable deployment of a network element, a software-defined networking (SDN) concept is proposed in the industry. In SDN, control logic and a forwarding function of network elements are decoupled, and the control logic is centrally deployed. A control-plane device whose control logic is centrally deployed is operated, so that network control and maintenance can be easily performed, network management efficiency is improved, and a forwarding-plane device is simplified and generalized. The OpenFlow protocol is a typical technology in an SDN.
Network elements in the OpenFlow protocol include a controller and a Switch. The controller is responsible for determining, according to a feature of a packet, a forwarding action of the service flow, and delivering a corresponding flow rule and a corresponding action to the switch. The switch obtains and stores the flow rule, and performs the corresponding action on a subsequent packet that complies with the flow rule, so as to forward or process the packet. In a scenario in which a packet fails to match a flow entry, the switch may report the event to the controller by using a first packet message Packet_in, and the controller sends a processing action of the packet to the switch by using a second packet message Packet_out. Currently, there are three manners in which the switch processes a Packet_out message. In a first manner, the Switch performs matching, starting at a flow table at a first level, on a packet carried in the Packet_out message, and performs flow table-based pipeline processing on the packet. In a second manner, the controller adds, into the Packet_out message, a location of a flow table that causes Packet_in, and the switch processes a packet according to a value of the location of the flow table and starting at a specified flow table. In a third manner, the Packet_out message carries an action set for processing a packet, and the switch processes the packet according to the action set without a need to perform matching by using a pipeline.
However, in the foregoing three manners, the switch totally processes a packet according to an instruction of the controller, and when a modified packet still needs to be submitted to a control plane for processing, and is subsequently returned by the controller to the switch for processing, information is lost due to the previous modification.